"""
CloseCommand.py

This class is intended to represent a close command.  

Author: Ryan Walters
Date: 10-12-08

$Id: CloseCommand.py 324 2008-10-17 02:18:09Z malerba89 $
"""

import sys
from Command import Command

class CloseCommand(Command):

    #Initialization, should be called with each new game
    #players is a list of players that should be notified when this commans
    #is executed
    def __init__(self, log, players):
        self.log_command = log
        self.players = players
        
    # A function for closing the game
    def execute(self):
        if self.log_command is not None:
            self.log_command.execute(None)
        for player in self.players:
            player.handleCommandExecuted('exit')
        sys.exit(0)

    # A function to be invoked each time the log is toggled
    def update_log_reference(self, log):
        self.log_command = log
